#include"PoseManage.hpp"
namespace adas {
PoseManage::PoseManage(const Pose& pose) noexcept
{
    this->pose = pose;
}

void PoseManage::Move(void) noexcept
{
    if (this->pose.heading == 'N')
        this->pose.y++;
    if (this->pose.heading == 'S')
        this->pose.y--;
    if (this->pose.heading == 'E')
        this->pose.x++;
    if (this->pose.heading == 'W')
        this->pose.x--;
}

void PoseManage::Retreat(void) noexcept
{
    if (this->pose.heading == 'N')
        this->pose.y--;
    if (this->pose.heading == 'S')
        this->pose.y++;
    if (this->pose.heading == 'E')
        this->pose.x--;
    if (this->pose.heading == 'W')
        this->pose.x++;
}

void PoseManage::TurnLeft(void) noexcept
{
    switch (this->pose.heading) {
    case 'N':
        this->pose.heading = 'W';
        break;
    case 'W':
        this->pose.heading = 'S';
        break;
    case 'S':
        this->pose.heading = 'E';
        break;
    case 'E':
        this->pose.heading = 'N';
        break;
    default:
        this->pose.heading = 'N';
        break;
    }
}

void PoseManage::TurnRight(void) noexcept
{
    switch (this->pose.heading) {
    case 'N':
        this->pose.heading = 'E';
        break;
    case 'W':
        this->pose.heading = 'N';
        break;
    case 'S':
        this->pose.heading = 'W';
        break;
    case 'E':
        this->pose.heading = 'S';
        break;
    default:
        this->pose.heading = 'N';
        break;
    }
}

Pose PoseManage::Query(void) const noexcept
{
    return this->pose;
}

Pose PoseManage::operator=(const Pose& pose) noexcept
{
    this->pose.x = pose.x;
    this->pose.y = pose.y;
    this->pose.heading = pose.heading;
    return this->pose;
}

void PoseManage::Fast(void) noexcept
{
    this->fast = !this->fast;
}

void PoseManage::Back(void) noexcept
{
    this->back = !this->back;
}

bool PoseManage::isFast(void) noexcept
{
    return this->fast;
}

bool PoseManage::isBack(void) noexcept
{
    return this->back;
}
}